// import React, { useState } from 'react'
// interface STATETYPE{
//   name?:string,
//   age?:number,
//   title?:DATATYPE[],
// }

// interface DATATYPE{
//   id:string,
//   money:number
// }

// export default function My() {
//   const [num,setNum] = useState<number>(0)
//   const [srt,setStr] = useState<string>('0')
//   const [bol,setBol] = useState<boolean>(true);
//   const [obj,setObj] = useState<STATETYPE>({});
//   const [rtyArr,setTryArr] = useState<Array<string>>(['123'])
//   const [test,setTest] = useState<Array<STATETYPE>>([{
//     name:'123456',
//     age:18,
//     title:[{id:'胡子瑜',money:111}]
//   }])

//   const [data,setdata] = useState<Array<DATATYPE>>([{
//     id:'123',
//     money:123
//   }])

//   return (
//     <div>My</div>
//   )
// }



import React, { useContext, useState } from 'react'
const MyCintext = React.createContext(0)

const Childe1 = () => {
  const num = useContext(MyCintext)
  return <div>
    Childe1:{num}
  </div>
}

const Childe2 = () => {
  const num2 = useContext(MyCintext)
  return <div>
    Childe2:{num2}
  </div>
}

export default function My() {
  const [num, setNum] = useState<number>(0)
  const handleClick = () => {
    console.log(123);
    setNum(num + 1)

  }
  return (
    <div>
      <button onClick={() => handleClick()}>
        <p>num 是值是{num}</p>
        <MyCintext.Provider value={num}>
          <Childe1 />
          <Childe2 />
        </MyCintext.Provider>

      </button>
    </div>
  )
}



